package com.xbongbong.pro.model.impl;

import com.xbongbong.pro.domain.dao.FormLabelDao;
import com.xbongbong.pro.domain.entity.FormLabelEntity;
import com.xbongbong.pro.model.FormLabelModel;
import com.xbongbong.saas.constant.ParameterConstant;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 */
@Service("formLabelModel")
public class FormLabelModelImpl implements FormLabelModel {
    @Resource
    private FormLabelDao formLabelDao;

    @Override
    public Long insert(FormLabelEntity entity) {
        return formLabelDao.insert(entity);
    }

    @Override
    public void insertBatch(List<FormLabelEntity> list) {
        formLabelDao.insertBatch(list);
    }

    @Override
    public List<FormLabelEntity> findEntities(Map<String, Object> param) {
        return formLabelDao.findEntities(param);
    }

    @Override
    public Integer getEntityCount(Map<String, Object> param) {
        return formLabelDao.getEntitiesCount(param);
    }

    @Override
    public void update(FormLabelEntity entity) {
        formLabelDao.update(entity);
    }

    @Override
    public FormLabelEntity getByKey(Long key, String corpid) {
        return formLabelDao.getByKey(key, corpid);
    }

    @Override
    public List<FormLabelEntity> getByLabelIdIn(String corpid, List<Long> ids) {
        if (CollectionUtils.isEmpty(ids)) {
            return new ArrayList<>();
        }
        Map<String, Object> param = new HashMap<>();
        param.put(ParameterConstant.CORPID, corpid);
        param.put("idIn", ids);
        return formLabelDao.findEntities(param);
    }

    @Override
    public Integer updateBatch(List<FormLabelEntity> formLabelEntities, String corpid) {
        return formLabelDao.updateBatch(formLabelEntities, corpid);
    }

}
